public class JShell {

	/**
	 * @param args
	 */
	
	//Main Program
	public static void main(String[] args) {
		
		//initialize objects
		IJSInputOutput jsPrompt = new JSInputOutput();
		IJSParser jsParse = new JSParser();
		IJSCommands jsCommand = new JSCommands();
		JSDirectory jsDir = new JSDirectory();
		
		//initialize variables
		String workDir = jsDir.getAddress();
		String input;
		String output;
		
		//exit flag
		Boolean exit = false;
		
		//Continue to run until exit condition
		while (!exit) {
		
			//Prompt for user input
			input = jsPrompt.userPrompt(workDir);
			
			// Continue to operate on input only if the input has content,
			// i.e., if the user hasn't merely pressed Enter
			if (input.length() != 0) {
			
				//Check for exit condition
				if (input.compareToIgnoreCase("exit") == 0) {
					exit = true;
					jsPrompt.print("Exiting");
					
				// Check for the empty input, i.e. if user merely pressed Enter
				// Else compute appropriate output and continue to prompt
				} else {
					output = jsCommand.runCommand(jsParse.parseString(input)); 
					jsPrompt.print(output);
				}

			}
		}
	}

}
